//
//  WPPhysicalExaminationFileVC.m
//  wobingwoyi
//
//  Created by WGP on 2017/3/1.
//  Copyright © 2017年 WGP. All rights reserved.
//

#import "WPPhysicalExaminationFileVC.h"
#import "WPPEFTableViewCell.h"
#import "UITableView+FDTemplateLayoutCell.h"
#import "WPPEFModel.h"
#import "WPAddPEFVC.h"

@interface WPPhysicalExaminationFileVC ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UIImageView *imageView;
@property(nonatomic,strong)UILabel *nothingTipLabel;
@property(nonatomic,strong)UIButton *addFileBtn;
@property(nonatomic,strong)UIButton *blueAddFileBtn;
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSArray *models;

@end

@implementation WPPhysicalExaminationFileVC

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.titleLabel.text = @"体检档案";
    self.view.backgroundColor = GlobalBgColor;
    
    [self setupUI];
    
    WPPEFModel *model1 = [WPPEFModel new];
    model1.descStr = @"2月28日上午，广东省公安厅通报，广东省警方近日集中开展的“飓风1号”专案收网行动，";
    model1.title = @"16年体检报告";
    model1.timeStr = @"2016-09-21";
    WPPEFModel *model2 = [WPPEFModel new];
    model2.timeStr = @"2016-09-21";
    model2.descStr = @"成功摧毁侵犯公民个人信息犯罪团伙6个，捣毁犯罪窝点14个，抓获犯罪嫌疑人138名，缴获涉及全国公民个人信息近1亿条，查扣银行卡2000余张和电脑、手机、存储设备一批。";
    WPPEFModel *model3 = [WPPEFModel new];
    model3.timeStr = @"2016-09-21";
    model3.descStr = @"广州警方派出1千多名警力，赴各涉案地开展侦控和抓捕工作。据了解，27日早上7点，抓捕行动开始，各路警力迅速出击。据悉，2016年年底，广州市公安局摧毁了一个买卖公民个人信息的团伙，经过扩线经营，又排查出6个涉嫌侵犯公民个人信息犯罪团伙。";
    self.models = @[model1,model2,model3];
}

-(void)setupUI
{
    self.imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tijianda"]];
    [self.view addSubview:self.imageView];
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.navBarView.mas_bottom).offset(100*K_SCALE_ELSE_TABBAR);
    }];
    
    self.nothingTipLabel = [UILabel new];
    self.nothingTipLabel.text = @"暂无体检报告形成的健康档案";
    self.nothingTipLabel.textColor = [UIColor colorWithHexString:@"#999999"];
    self.nothingTipLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.nothingTipLabel];
    [self.nothingTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.imageView.mas_bottom).offset(30);
    }];
    
    self.addFileBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.addFileBtn setBackgroundImage:[UIImage imageNamed:@"add"] forState:UIControlStateNormal];
    [self.addFileBtn addTarget:self action:@selector(addFileBtnDidClick) forControlEvents:UIControlEventTouchDown];
    [self.navBarView addSubview:self.addFileBtn];
    [self.addFileBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.navBarView);
        make.right.equalTo(self.navBarView).offset(-10);
    }];
    
    self.blueAddFileBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.blueAddFileBtn setTitle:@"添加体检档案" forState:UIControlStateNormal];
    self.blueAddFileBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [self.blueAddFileBtn setBackgroundImage:[UIImage imageNamed:@"normal"] forState:UIControlStateNormal];
    [self.blueAddFileBtn setBackgroundImage:[UIImage imageNamed:@"highLight"] forState:UIControlStateHighlighted];
    [self.blueAddFileBtn addTarget:self action:@selector(addFileBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.blueAddFileBtn];
    [self.blueAddFileBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.left.equalTo(self.view).offset(30);
        make.right.equalTo(self.view).offset(-30);
        make.top.equalTo(self.nothingTipLabel.mas_bottom).offset(64);
    }];
    
    self.tableView = [[UITableView alloc] init];
    self.tableView.backgroundColor = GlobalBgColor;
    [self.view addSubview:self.tableView];
    [self.tableView registerClass:[WPPEFTableViewCell class] forCellReuseIdentifier:@"WPPEFTableViewCell"];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.view);
        make.top.equalTo(self.navBarView.mas_bottom);
    }];
}

-(void)addFileBtnDidClick
{
    WPAddPEFVC *vc = [WPAddPEFVC new];
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - UITableView 的代理和数据源方法

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WPPEFTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WPPEFTableViewCell" forIndexPath:indexPath];
    cell.model = self.models[indexPath.item];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [tableView fd_heightForCellWithIdentifier:@"WPPEFTableViewCell" cacheByIndexPath:indexPath configuration:^(WPPEFTableViewCell *cell) {
        // 配置 cell 的数据源，和 "cellForRow" 干的事一致，比如：
        cell.model = self.models[indexPath.item];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
